"""配置管理模块"""
import configparser
import os

class Config:
    """应用配置类"""
    def __init__(self, config_file='config.ini'):
        self.config = configparser.ConfigParser()
        self.config.read(config_file, encoding='utf-8')
        
        # 数据库配置
        self.MYSQL_HOST = self.config['database']['HOST']
        self.MYSQL_USER = self.config['database']['USER']
        self.MYSQL_PASSWORD = self.config['database']['PASSWORD']
        self.MYSQL_DB = self.config['database']['DB']
        self.MYSQL_PORT = int(self.config['database']['PORT'])
        
        # 上传配置
        self.UPLOAD_FOLDER = self.config['upload']['UPLOAD_FOLDER']
        self.MAX_CONTENT_LENGTH = int(self.config['upload']['MAX_CONTENT_LENGTH'])
        
        # 允许的文件扩展名
        self.ALLOWED_EXTENSIONS = set(
            self.config['allowed_extensions']['ALLOWED'].split(',')
        )
        
        # 应用配置
        self.SECRET_KEY = self.config['app']['SECRET_KEY']

# 全局配置实例
config = Config()

